const password_update = async() => {
    let oldp = document.querySelector('.oldpassword').value,
        newp = document.querySelector('.newpassword').value,
        relp = document.querySelector('.relpassword').value
    if (oldp && newp && relp) {
        if (newp == relp) {
            let userinfo = localStorage.getItem('userinfo')
            if (userinfo) {
                userinfo = JSON.parse(userinfo)
                let obj = {
                    oldpassword: oldp,
                    newpassword: newp,
                    id: userinfo.id
                }
                try {
                    const response = await ajax('updatepassword', 'PUT', obj)
                    alert('密码修改成功!请重新登录')
                    localStorage.removeItem('userinfo')
                    window.parent.location.href = './login.html'
                } catch (error) {
                    alert(error.meta.msg)
                }

            } else {
                alert('当前登录身份失效，请重新登录后再操作')
            }
        } else {
            alert('两次密码输入不一致')
        }
    } else {
        alert('请输入密码')
    }
}